Most voted "monetary-value" questions
Use this tag in questions relating to the correct representation, manipulation and storage of data relating to monetary units (cash), in order to obtain correct results, consistent with market practice and in accordance with current legislation (IT Governance).
Learn more…34 questions
Sort by count of
-
111
votes7
answers13788
viewsHow to represent money in Javascript?
What is the best way to represent monetary units (i.e. money) in Javascript? I know it is not good to use floating point, given the rounding problem, but I do not know what would be the best…
-
25
votes5
answers80372
viewsHow to "round" a float in Python?
I have this sum: total = 0.1 + 0.2 print total #retorna 0.30000000000000004 How would I "round" the decimal places and return only the number of places summed? Example: totalA = 0.1 + 0.2…
-
15
votes2
answers2992
viewsDecimal places of the float
I am developing an application to control product sales. However, sometimes the added value of reports does not beat decimal places. Gives small differences. How to make the float stop giving these…
-
12
votes1
answer2421
viewsWhat is the best way to store money in Sqlite?
Li that post on the lack of precision of double, and virtually every link in the post. Then I realized that this was a vulnerability of my software in production (since I have rounds to every corner…
-
8
votes3
answers4527
viewsRemove currency formatting and take only the PHP number
i write in the database the values of the products in this way: For example: R$ 5.000,00 How do I do in PHP to make this number stay 5000? That is to say "shape"? Do you have a function that fits…
-
8
votes1
answer14933
viewsDouble type and Decimal type, which is suitable for monetary value?
I found here in the SO a question with an answer until well accepted by the community What kind of data (double, float or decimal) should I use to represent currency in . NET with C#? I just never…
-
8
votes1
answer170
viewsWould it be bad practice to insert monetary symbols directly into the bank?
In a system I had to tamper with wage values and commissions, perform calculations on them and the like. However I went to analyze that the monetary symbols are being inserted directly in the…
-
7
votes4
answers1015
viewsProblem with pennies when using the Biginteger type
I’m having a problem adding up pennies. Informo 1200, returns 1.200,00 instead of 12,00. Code: formatar_data(1200); private int formatar_data(int inteiro){ BigInteger valor = new…
-
6
votes3
answers671
viewsCorrect pennies in Boletophp Bank Slips
I’m using the Boletophp project to generate bank slips, but I noticed that the pennies are not recorded correctly, because when I buy a product with the value of for example, R $ 245,00 plus the…
-
5
votes1
answer285
viewsFormatting decimal
I’m having a problem formatting decimals in my code in Objective-c, I would like to take advantage only 2 decimal places of my variable which is float. Ex: Value of the variable discount =…
-
5
votes2
answers345
viewsHow does the rounding of the string format work?
Consider the following code snippet: decimal myValue = 3.045M; Console.WriteLine("Result by Math.Round = " + Math.Round(myValue, 2)); Console.WriteLine("Result by string.Format = " +…
-
4
votes1
answer488
viewsDifferent numbers become equal after conversion with doubleval
I have 2 values 4850.00 and 4850.01 When I set 2 variables manually with these values and compare using if, returns me different (OK). But in an ERP system I develop I receive 2 values via AJAX.…
-
4
votes1
answer213
viewsDouble type variable precision problem
I’m solving the 1021 issue of the Judge URI, but I have a problem with the accuracy of my input value. Follow the base code: #include <iostream.h> int main(){ double a; cin >> a; } The…
-
4
votes2
answers884
viewsProblem with currency percentage and rounding
How to maintain monetary values with only 2 decimal places when performing percentage operations? Example: Total value: R$ 377,17 Percentage divisions: 33%, 33% and 34% Problem: the sum of the value…
-
3
votes1
answer1030
viewsConvert String to monetary value in ASP.NET MVC
How to convert the result of a multiplication into a string to display as Real? The value of bol.ValorBoleto is loaded just before. To data Annotation: [DisplayFormat(ApplyFormatInEditMode = false,…
-
3
votes3
answers1491
viewsHow to round Double values?
I made a function to return the rounding of values of type Double, the function is working, but I do not know if it is the ideal way to have this result, I think there must be a way without having…
-
3
votes1
answer7283
viewsHow to format monetary value in Laravel
I would like to know how to format monetary values in Laravel. Is there a Package or method that is for the framework? {{ $lst->vl_valor_tot_contrato }} is displayed with monetary formatting…
-
3
votes6
answers22035
viewsCompute the rest of a decimal division in Javascript
I’m working with values (decimal(18,2)) a sale where the sum of the price of the products is to be converted into a number of parcels. So that I can divide the total of the products exactly for the…
javascript mathematics decimal monetary-value divisionasked 8 years, 11 months ago LeandroLuk 4,989 -
3
votes2
answers4704
viewsComplete decimal places ",00" Javascript
People I have the following function that I am using to use Coin mask <input class="valr-parc" type="text" name="valr-parc" /> <script> String.prototype.Moeda = function() { var v =…
-
2
votes2
answers1325
viewsSum decimal places Javascript
I have 3 Javascript variables: valorUm = 2.8 //dois ponto oito valorDois = 2.415 //dois mil quatrocentos e 15 valorLivre = 25 //vinte e cinco What I need is: valorUm + valorDois - valorLivre this…
-
2
votes1
answer235
viewsAccuracy of float64
Why Go when performing the calculation: (1 * 0.09) + 0.36 returns a float64 in the following format 0.44999999999999996? I’m trying to make comparisons with tests and the calculation should be 0.45…
-
2
votes1
answer268
viewsHow to increase the number of decimals after the comma?
How can I make the field display 0.0000 for example ? By default it only arrow 2 houses, I’m not able to increase. Example: import javafx.beans.value.ChangeListener; import…
-
2
votes1
answer1551
viewsHow to make monetary mask on Edit Text Android
Good morning gentlemen, I’m having trouble putting a monetary mask on an Edit Text, I checked several forums and tutorials but no method worked. My project is to basically make the customer put the…
-
1
votes2
answers174
viewsMethod does not correctly show expected result
I have this interface public interface Promocional { boolean aplicaDesconto(double porcentagem); default boolean aplicaDescontoDe10Porcento() { return aplicaDesconto(0.1); } } The class LivroFisico…
-
1
votes2
answers66
viewsNumberformatter does not work MIN_FRACTION_DIGITS, 2
Good use of php’s Numberformatter library to work with conversion, but I’m having a problem converting numbers with many digits after the . Example: $valores = '54.98054562'; $moeda1 = new…
-
1
votes2
answers91
viewsJS not formatting the thousand value correctly for Input and not receiving correctly in PHP / Database
Good morning people, I have in my forms some input’s where the user informs the value of the product, its quantity and with this is made the calculation of the Product Value and also the Total Order…
-
1
votes1
answer218
viewsPrecision scaling using Entity Framework and SQL Server
There’s some time I’ve been noticing, something strange when saving values double in the SQL Server database with the Entity Framework. I noticed that when reporting a value ex: 12.23 after…
-
1
votes2
answers71
viewsAndroid Edittext type number make appear keyboard with numbers and comma
I am working with values in editText and I need the input to be only numbers and comma to floating point. I tried with inputType="numberDecimal" but when opening the keyboard only allows the point…
-
1
votes1
answer564
viewsPrevent character typing if monetary value is incorrect in Delphi
My goal, using Delphi 10.1, is to compare the text typed in an Edit, at the time of typing a new character, if the text format after typing the key (which can be typed at the end, beginning or…
-
1
votes2
answers608
viewsRegex to validate currency, fractionated, accepting negatives
I will use in Delphi 10.1. I managed to reach the expression below, but for lack of knowledge and practice, I’m not getting to where I want. Regex: ^(^[\-]?[1-9]|0)(?:[0-9]{0,10}|0)(?:,\d{0,2})?$ I…
-
0
votes1
answer1119
viewsConvert numeric value to javascript string
I am creating a receipt layout and I need the value of the receipt to be detailed in full in the body of the receipt, for example: Transform R$ 45,51 in Forty-five reais and fifty-one cents. Is…
-
0
votes0
answers78
viewsHow to determine if string is strictly decimal?
I would like that if the string has the comma (as we use in the Brazilian real to represent the decimal places), it returns true and if not, return false. Example: "1" = false; "1,00" = true; "10" =…
-
-2
votes2
answers3274
viewsHow to convert monetary number to extended number in Python
How can I convert a monetary number into an extended number using Python ?
-
-3
votes1
answer172
viewsHow to transform a monetary value into Reals in a number 7743;ero float?
I need to turn a number that is in the format 20.000,00 (with points in each thousand) for a type number float, how do I do that? var value = $('#money').val() var currency = value.replace(",00",…